package com.lwc.cfdns.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lwc.cfdns.pojo.entity.SystemAdminRole;
import com.lwc.cfdns.pojo.entity.SystemAdminStation;
import com.lwc.cfdns.service.SystemAdminStationService;
import com.lwc.cfdns.mapper.SystemAdminStationMapper;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author spring
 * @description 针对表【cfdns_system_admin_station(用户与岗位关联表（用户1-N岗位）)】的数据库操作Service实现
 * @createDate 2023-05-26 11:44:19
 */
@Service
public class SystemAdminStationServiceImpl extends ServiceImpl<SystemAdminStationMapper, SystemAdminStation>
        implements SystemAdminStationService {

    /**
     * 管理员岗位关系表
     *
     * @param id
     * @param stations
     * @return void
     * @throws
     * @version 1.0.0
     * @author luwc
     * @time 2023/5/26 13:50:31
     */
    @Override
    public boolean stations(Long id, List<Long> stations) {
        this.baseMapper.delete(new LambdaQueryWrapper<SystemAdminStation>().eq(SystemAdminStation::getAdminId, id));
        if (stations.size() > 0) {
            List<SystemAdminStation> batInsert = new ArrayList<>();
            for (Long statiion_id : stations) {
                SystemAdminStation systemAdminStation = new SystemAdminStation();
                systemAdminStation.setAdminId(id);
                systemAdminStation.setStationId(statiion_id);
                batInsert.add(systemAdminStation);
            }
            this.saveBatch(batInsert);
        }
        return false;
    }
}




